package com.example.client.http;

import com.example.client.ClientImpl;
import com.example.transport.message.Response;
import org.smartboot.socket.MessageProcessor;
import org.smartboot.socket.Protocol;
import org.smartboot.socket.transport.AioQuickClient;
import org.smartboot.socket.transport.AioSession;

import java.nio.ByteBuffer;

public class DefaultHttpClient extends ClientImpl {

    private AioQuickClient client;

    public DefaultHttpClient(String ip, int port) {
        super(ip, port);
    }

    @Override
    public void init() throws Exception {
        this.client = new AioQuickClient(getIp(), getPort(), new Protocol<Response>() {
            @Override
            public Response decode(ByteBuffer readBuffer, AioSession session) {
                return null;
            }
        }, new MessageProcessor<Response>() {
            @Override
            public void process(AioSession session, Response msg) {

            }
        });
    }

    @Override
    public void start() throws Exception {
        this.client.start();
    }

    @Override
    public void stop() throws Exception {
        this.client.shutdownNow();
    }
}
